package expression;

import java.util.LinkedList;

public class FnBoolGreaterEqual extends Fn implements FnBool {

	boolean strings = false;

	@Override
	protected boolean isAcceptableChild(Fn fn) {
		return (fn instanceof FnNumber && !strings) || (fn instanceof FnString && (strings = true));
	}

	@Override
	protected boolean isAcceptableParam(Object o) {
		return (o instanceof Number && !strings) || (o instanceof String && (strings = true));
	}

	@Override
	public int getNParam() {
		return 2;
	}

	@Override
	protected int precedence() {
		return 4;
	}

	@Override
	protected Object value(LinkedList<Object> param) {
		Object o1 = param.get(0);
		Object o2 = param.get(1);
		if (strings)
			return ((String) o1).compareTo((String) o2) >= 0;
		else
			return (new Double(((Number) o1).doubleValue())).compareTo(new Double(((Number) o2).doubleValue())) >= 0;
	}

	@Override
	public String symbol() {
		return ">=";
	}

	@Override
	protected String[] notation() {
		return new String[]
		{ "", " >= ", "" };
	}

}
